package com.yx;

import javax.servlet.Servlet;
import java.util.HashMap;
import java.util.Map;

public class Context {
    private String appName;
    //保存servlet和urlPattern的映射关系
    public Map<String, Servlet> urlPatternMapping=new HashMap<>();

    public Context(String appName) {
        this.appName = appName;
    }
    public void addUrlPatternMapping(String urlPattern,Servlet servlet){
        urlPatternMapping.put(urlPattern,servlet);
    }
    public Servlet getByUrlPattern(String urlPattern){
        for(String key:urlPatternMapping.keySet()){
            if(key.contains(urlPattern)){
                return urlPatternMapping.get(key);
            }
        }return null;
    }

}

